Skip to content

Preserve raw bytes in IMAP APPEND#109

Merged
qnikst merged 3 commits into
qnikst:masterfrom
mpscholten:upstream/imap-append-raw-bytes
Jun 12, 2026
Merged

Preserve raw bytes in IMAP APPEND#109
qnikst merged 3 commits into
qnikst:masterfrom
mpscholten:upstream/imap-append-raw-bytes

Conversation

@mpscholten

Copy link
Copy Markdown
Contributor

Fixes #102.

appendFull currently splits the rendered message with BS.lines, computes a new literal size from those split lines, and sends each line with bsPutCrLf. That mutates already-rendered RFC 5322/MIME bytes: CRLF input becomes CRCRLF on the wire and the literal size no longer matches the original message size.

This PR keeps the public API unchanged and sends the APPEND literal exactly as supplied:

  • literal size is BS.length mailData
  • mailData is written once with bsPut
  • the final IMAP literal terminator CRLF is still sent afterwards

Regression coverage:

  • IMAP.append conn "INBOX" "Subject: x\r\n\r\nBody\r\n" sends the exact raw message bytes after the APPEND command.

Before the fix, the new regression failed with {23} and doubled carriage returns. After the fix it passes with {20} and unchanged message bytes.

Validation:

  • nix shell nixpkgs#cabal-install nixpkgs#ghc --command cabal test imap-parsers --test-show-details=direct
  • nix shell nixpkgs#cabal-install nixpkgs#ghc --command cabal build all
  • nix shell nixpkgs#cabal-install nixpkgs#ghc --command cabal check (only the existing CHANGELOG doc-place warning remains)
  • git diff --check

Note: this includes the same imap-parsers test-target setup and https:// repository metadata fix as the other small upstream PRs because the branch is independently based on upstream master. It can be rebased to drop that overlap after the first test-target PR merges.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 62fdff5430

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread test/IMAPParsersTest.hs
@mpscholten mpscholten force-pushed the upstream/imap-append-raw-bytes branch from afb5f56 to 6c71a13 Compare June 5, 2026 14:43
mpscholten and others added 2 commits June 10, 2026 20:06
…d-raw-bytes

# Conflicts:
#	HaskellNet.cabal
#	test/IMAPParsersTest.hs
Combines mailbox quoting from master (PR qnikst#108) with raw byte
preservation in IMAP APPEND. Updated test expectations to match
the new appendFull implementation (bsPut + len = BS.length mailData).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mpscholten

Copy link
Copy Markdown
Contributor Author

@qnikst thanks for merging all the previous PRs already :) is this one good to go as well?

@qnikst qnikst merged commit a2c4ea8 into qnikst:master Jun 12, 2026
23 checks passed
@qnikst

qnikst commented Jun 12, 2026

Copy link
Copy Markdown
Owner

This one is good to go as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

appendFull is broken with MIME messages

2 participants